package no.uib.hplims.views;

import com.vaadin.terminal.ThemeResource;
import com.vaadin.ui.Component;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.VerticalLayout;

public abstract class AbstractParentTab extends VerticalLayout {

	private static final long serialVersionUID = 5117017438304197976L;
	
	private TabSheet tabSheet = null;
	private VerticalLayout mainTab = null;
	
	public AbstractParentTab(String caption, ThemeResource icon) {
		
		tabSheet = new TabSheet();
		
		mainTab = new VerticalLayout();
		mainTab.setCaption(caption);
		mainTab.setIcon(icon);
		mainTab.setMargin(true, true, true, true);
		
		tabSheet.addComponent(mainTab);
		this.addComponent(tabSheet);
	}
	
	public TabSheet getTabSheet() {
		return tabSheet;
	}

	public void setTabSheet(TabSheet tabSheet) {
		this.tabSheet = tabSheet;
	}

	public VerticalLayout getMainTab() {
		return mainTab;
	}

	public void setMainTab(VerticalLayout mainTab) {
		this.mainTab = mainTab;
	}

	protected abstract void init();
	
	public abstract void activated(Object... params);
	
	public void addNewClosableTab(Component tab) {
		tabSheet.addTab(tab);
		tabSheet.getTab(tab).setClosable(true);
		tabSheet.setSelectedTab(tab);
	}

}
